home *** CD-ROM | disk | FTP | other *** search
/ SunSoft Catalyst CDWARE 1996 May to August / Catalyst CDWARE 1996 May to August.iso / .products / .bin / httpd / Solaris_1 / create_index.pl < prev    next >
Perl Script  |  1996-02-29  |  2KB  |  73 lines

  1. #!./perl
  2.  
  3. # ------------------------------------------------------------
  4.  
  5. # create_index.pl, by Jean-Pierre Girard (jpg@corrado.sun.com)
  6. # This edit in real-time the home page file
  7. # necessary for the CDware.
  8.  
  9. # ------------------------------------------------------------
  10.  
  11. # Bugs and other fixes
  12.  
  13. # ------------------------------------------------------------
  14.  
  15. ##############################################################################
  16. # Main block
  17. ##############################################################################
  18. if ($ENV{'REQUEST_METHOD'} eq "POST") {
  19.     read(STDIN, $request, $ENV{'CONTENT_LENGTH'});
  20. } elsif ($ENV{'REQUEST_METHOD'} eq "GET" ) {
  21.     $request = $ENV{'QUERY_STRING'};
  22. }
  23.  
  24. $~ = "HTMLHEADER";
  25. write STDOUT;
  26.  
  27. #@names = &url_decode(split(/[&=]/, $request));
  28. #%rqpairs = @names;
  29. #$Products[1] = $rqpairs{"Product2"};
  30.  
  31. print "ARGV=$ARGV[0]<br>, request=$request<br>";
  32.  
  33. if ($ARGV[0] eq "HTML") {
  34. } elsif ($request eq "") {
  35.     print "no request";
  36. } else {
  37. }
  38. for $key (sort keys %ENV) {
  39.     print "$key=$ENV{$key}<br>";
  40. }
  41. $HomeDir = $request;
  42. $HomeDir =~ s?.*/([^/]*)/[^/]*$?../\1?;
  43. $ENV{"SCRIPT_NAME"}=$HomeDir;
  44. $HomeDir = $request;
  45. $HomeDir =~ s?(.*)/[^/]*$?\1?;
  46. print "HomeDir=$HomeDir<br>";
  47. exec("cd $HomeDir;echo \"Content-type: text/html\n\n\n<html><body>\";echo $HomeDir;cat $request");
  48. print $ENV{"SCRIPT_NAME"}, "<br>, pwd=", `pwd`, "<br>";
  49. $INDEXFILENAME=$request;
  50.  
  51.     unless (open (INDEXFILE, "$INDEXFILENAME")) {
  52.         #&PrintErr("NoCreation", $INDEXFILENAME);
  53.         #print "<H3><dd><img ALIGN=middle src=\"file:///tmp/httpd/.products/CDware/images/error.gif\">Cannot create $INDEXFILENAME</H3></dd><br>";
  54.     } else {
  55.         while (<INDEXFILE>) {
  56.             print STDOUT $_;
  57.         }
  58.     }
  59.  
  60.  
  61. ################################################################################
  62. # Define FORMATS (no more code)
  63. ################################################################################
  64. format HTMLHEADER =
  65. Content-type: text/html
  66.  
  67.  
  68. <html>
  69. <title>Developer's Kit</title>
  70. <body>
  71. .
  72.  
  73.